#include "MiscObject.h"

void MiscObject::Release() {
	mesh.Release();
	meshInst.Release();
}

bool MiscObject::Initialize(LPDIRECT3DDEVICE9 pDevice) {
	group = 0;
	order = 0;
	hRadius = 1.0f;
	alignment = "Neutral";
	dataFile = " ";
	if(modelFile.empty())
		modelFile = " ";
	name = "Unnamed";
	purpose = "Win";
	type = "BEACON";

	if(!InitializeMesh(pDevice))
		return false;
	
	return true;
}

bool MiscObject::InitializeMesh(LPDIRECT3DDEVICE9 pDevice) {
	if(modelFile != " ") {
		//PRINT("Reading from model file: ");
		//PRINT(modelFile.c_str());	NEXT_LINE;
		if(!mesh.Load(pDevice, modelFile)) {
			SHOWERROR("mesh.Load() - Failed", __FILE__, __LINE__);
			return false;
		}
		meshInst.setMesh(&mesh);
	} else {
		PRINT("Model file name not specified, current entry: ");
		PRINT(modelFile.c_str());	NEXT_LINE;
		return false;
	}

	return true;
}

void MiscObject::Render(LPDIRECT3DDEVICE9 pDevice) {
	meshInst.Render(pDevice);
}
